import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import org.qtproject.znews_qt 1.0

import "../common"
import "../delegate"


Rectangle {
    id: id_contentRow

    property int m_margin: 10 * ApplicationInfo.ratio
    property int heightContentRow;
    property string contentText: contentRow

    x : m_margin
    y: m_margin

    width: parent.width - 2* m_margin // 10 de hien thi scrollbar
    height: id_rowLayout.height


    Row{
        id: id_rowLayout
        width: parent.width

        Component.onCompleted: {
            if (type===0) {
                id_columnImage.visible = false;
                id_imageContentRow.visible = false;
                id_waitingForm.visible = false;

                id_textContentRow.text = contentText;

            } else {
                id_textContentRow.visible = false;

                id_imageContentRow.source = contentText;
            }
        }

        Column{
            id: id_columnImage
            width: parent.width

            Image {
                id: id_imageContentRow
                width: parent.width
                height: 480 * ApplicationInfo.ratio

                visible: false

                onStatusChanged: {
                    if (id_imageContentRow.status == Image.Ready) {
                        id_imageContentRow.visible = true;
                        id_waitingForm.visible = false;

                    }
                }

            }

            ContentWaitingImage {
                id: id_waitingForm
                visible: true;
                width: parent.width
                height: 150  * ApplicationInfo.ratio
            }

        }


        Text {
            id: id_textContentRow
            width: id_rowLayout.width - 10
            text: contentText
            font.family: "Arial"
            horizontalAlignment: Text.AlignJustify
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere

        }

    }

    MouseArea {
        anchors.fill: id_contentRow
        onClicked: {
            console.log("content Row MouseArea: type = " + type );
            if (type == 1) {
                displayImage(contentText);
            }
        }
    }

}
